// pages/message_center/message_center.js
const app = getApp(), core = require('../../utils/core');
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    core.get({
      url: 'xilujob.message/summary',
      success: ret => {
        this.setData(ret.data);
      }
    })
  },
  bindGoPersonal() {
    let total = this.data.personal.total;
    if(total>0) {
      this.setData({'personal.total':0});
      app.eventBus.emit(app.Events.ClearMessageCount, total);
    }
    wx.navigateTo({url: '/pages/message_list/message_list?type=personal'});
  },
  bindGoActivity() {
    let total = this.data.activity.total;
    if(total>0) {
      this.setData({'activity.total':0});
      app.eventBus.emit(app.Events.ClearMessageCount, total);
    }
    wx.navigateTo({url: '/pages/message_list/message_list?type=activity'});
  },
  bindGoSystem() {
    let total = this.data.system.total;
    if(total>0) {
      this.setData({'system.total':0});
      app.eventBus.emit(app.Events.ClearMessageCount, total);
    }
    wx.navigateTo({url: '/pages/message_list/message_list?type=system'});
  }


});
